#ifndef HARMONY_CRYPTO_LOG_H
#define HARMONY_CRYPTO_LOG_H

#include <hilog/log.h>

#if defined(DEBUG)
#define LOG_PRINT(...) OH_LOG_Print(LOG_APP, LOG_INFO, 0x0, "ft_log", __VA_ARGS__);
#define LOG_PRINT_HEX(tag, src, len)                                                                                   \
    {                                                                                                                  \
        char _log_buf[4096] = {0};                                                                                     \
        const char *_log_tag = (const char *)(tag);                                                                    \
        memcpy(_log_buf, _log_tag, strlen(_log_tag));                                                                  \
        const unsigned char *_log_src = (const unsigned char *)(src);                                                  \
        size_t _log_len = (size_t)(len);                                                                               \
        size_t _log_pos = strlen(_log_tag);                                                                            \
        for (size_t _log_i = 0; _log_i < _log_len; ++_log_i) {                                                         \
            size_t _log_remain = sizeof(_log_buf) - _log_pos;                                                          \
            int _written = snprintf(_log_buf + _log_pos, _log_remain, " %02X", _log_src[_log_i]);                      \
            _log_pos += _written;                                                                                      \
        }                                                                                                              \
        LOG_PRINT("%{public}s", _log_buf);                                                                             \
    }
#else /* defined (DEBUG) */
#define LOG_PRINT(...)
#define LOG_PRINT_HEX(tag, src, len)
#endif /* defined (DEBUG) */

#endif // HARMONY_CRYPTO_LOG_H
